import { IPSSysBDScheme } from '../../ba/ipssys-bdscheme';
import { IPSSysBDTable } from '../../ba/ipssys-bdtable';
import { IPSDELogic } from './ipsdelogic';
import { IPSDELogicParam } from './ipsdelogic-param';
import { IPSDESysBDTableActionLogic } from './ipsdesys-bdtable-action-logic';
import { PSDELogicNodeImpl } from './psdelogic-node-impl';

export class PSDESysBDTableActionLogicImpl extends PSDELogicNodeImpl implements IPSDESysBDTableActionLogic {
  get bDTableAction(): 'CREATE' | 'UPDATE' | 'READ' | 'DELETE' {
    return this.M.bDTableAction;
  }

  protected dstpsdelogicparam: IPSDELogicParam | null = null;

  getDstPSDELogicParam(): IPSDELogicParam | null {
    if (this.dstpsdelogicparam != null) return this.dstpsdelogicparam;
    const value = this.M.getDstPSDELogicParam;
    if (value == null) {
      return null;
    }
    const ipsdelogic = this.getParentPSModelObject('dataentity.logic.IPSDELogic') as IPSDELogic;
    if (ipsdelogic != null) {
      this.dstpsdelogicparam = ipsdelogic.findPSDELogicParam(value);
    }
    return this.dstpsdelogicparam;
  }

  get dstPSDELogicParam(): IPSDELogicParam | null {
    return this.getDstPSDELogicParam();
  }

  getDstPSDELogicParamMust(): IPSDELogicParam {
    const value = this.getDstPSDELogicParam();
    if (value == null) {
      throw new Error('未指定目标逻辑参数对象');
    }
    return value;
  }

  protected pssysbdscheme: IPSSysBDScheme | null = null;

  getPSSysBDScheme(): IPSSysBDScheme | null {
    if (this.pssysbdscheme != null) return this.pssysbdscheme;
    const value = this.M.getPSSysBDScheme;
    if (value == null) {
      return null;
    }
    this.pssysbdscheme = this.getPSModel4('ba.IPSSysBDScheme', value, 'getPSSysBDScheme') as IPSSysBDScheme;
    return this.pssysbdscheme;
  }

  get psSysBDScheme(): IPSSysBDScheme | null {
    return this.getPSSysBDScheme();
  }

  getPSSysBDSchemeMust(): IPSSysBDScheme {
    const value = this.getPSSysBDScheme();
    if (value == null) {
      throw new Error('未指定大数据体系');
    }
    return value;
  }

  protected pssysbdtable: IPSSysBDTable | null = null;

  getPSSysBDTable(): IPSSysBDTable | null {
    if (this.pssysbdtable != null) return this.pssysbdtable;
    const value = this.M.getPSSysBDTable;
    if (value == null) {
      return null;
    }
    const ipssysbdscheme = this.getPSSysBDScheme();
    if (ipssysbdscheme != null) {
      this.pssysbdtable = ipssysbdscheme.findPSSysBDTable(value);
    }
    return this.pssysbdtable;
  }

  get psSysBDTable(): IPSSysBDTable | null {
    return this.getPSSysBDTable();
  }

  getPSSysBDTableMust(): IPSSysBDTable {
    const value = this.getPSSysBDTable();
    if (value == null) {
      throw new Error('未指定数据表');
    }
    return value;
  }

  get cls(): string {
    return 'PSDESysBDTableActionLogicImpl';
  }

  instanceof(cls: string): boolean {
    if (cls == 'dataentity.logic.IPSDESysBDTableActionLogic') return true;
    return super.instanceof(cls);
  }
}
